#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>


int main()
{
    const char * filename = "./test.txt";
    int fd = open(filename,O_RDONLY | O_CREAT,0644);
    if(fd == -1)
    {
        perror("open error:");
        exit(-1);
    }
    printf("fd = %d\n",fd);

    /*绝对路径 /home/lvguanzhong/268第二阶段/268class/268SystemPramgram/IOPramgram*/
    const char * filename2 = "./dst.txt";
    int fd2 =  open(filename2,O_WRONLY | O_CREAT,0777);
    if(fd2 == -1)
    {
        perror("open error:");
        exit(-1);
    }
    printf("fd2 = %d\n",fd2);

    /*关闭文件fd*/
    close(fd);

    const char * filename3 = "./file3.txt";
    int fd3 =  open(filename3,O_WRONLY | O_CREAT,0777);
    if(fd3 == -1)
    {
        perror("open error:");
        exit(-1);
    }
    printf("fd3 = %d\n",fd3);
    return 0;
}